<!-- 列表 -->
<extend name="Public:layout" />
<block name="title"><{$authName}></block>

<block name="pluginCSS">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/plugins/select2/select2.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/plugins/select2/select2-metronic.css"/>
</block>
<block name="CSS"></block>

<block name="loadJS">

<script type="text/javascript" src="__PUBLIC__/Admin/plugins/select2/select2.min.js"></script>
<script src="__PUBLIC__/admin/scripts/layer/layer.js" type="text/javascript"></script>	


</block>
<block name="setJS">
<script>
var ajaxUrl="<{:U('index')}>";
function delUsers(id,userType){
	message=(userType==1)?'<span class="text-danger">该用户为商家，删除该用户将下架其所有商品，确定删除吗？</span>':'确定删除该用户？';
	layer.confirm(message,function(index){
		$.post(ajaxUrl,{id:id,ajax:'delUsers'},function(data){
			
			if(data){
				layer.msg('用户删除成功！',{icon: 1,time: 2000});
				location.reload();
				
			}else{
				layer.msg('用户删除失败！',{icon: 2,time: 2000});
				return;
			}
	   });					
	});	
}

function userStatus(id,userStatus){
	$.post(ajaxUrl,{id:id,ajax:'userStatus',userStatus:userStatus},function(data){
		if(data){
			layer.msg('用户状态修改成功！',{icon: 1,time: 2000});
			location.reload();
			
		}else{
			layer.msg('用户状态修改失败！',{icon: 2,time: 2000});
			return;
		}
	});		 
} 
</script>
</block>
<block name="initJS">
$('#searchNum').change(function(){
	var pageSize= $(this).val();
	location.href="<{:U('index')}>?pageSize="+pageSize;
});


</block>

<block name="pagetitle">增删改查</block>
<block name="page">
<div class="row">
	<div class="col-md-12">

		<div class="portlet">
			<div class="portlet-title">
				<div class="caption">
					<i class="fa <{$authIco}>"></i><{$authName}>
				</div>
				
				<div class="actions">
					<a class="btn default green-stripe" id="table_common_new" data-toggle="modal" href="<{:U('edit')}>">
						<i class="fa fa-plus"></i>
						<span class="hidden-480">添加用户</span>
					</a>
				</div>
				
			</div>
			<div class="portlet-body">

				<label>
				   <select class="form-control" name="searchNum" id="searchNum">
				   <if condition="$PQ['pageSize'] eq 1">selected</if>
				   <option <if condition="$PQ['pageSize'] eq 5">selected</if> value="5">每页显示5条记录</option>
				   <option <if condition="$PQ['pageSize'] eq 15">selected</if> value="15">每页显示15条记录</option>
				   <option <if condition="$PQ['pageSize'] eq 20">selected</if> value="20">每页显示20条记录</option>
				   </select>
				</label>
				<div class="pull-right">
				<form class="form-inline" role="form" action="<{:U('index')}>" method="post">
				
       
       				<div class="form-group">
						<label class="sr-only" for="shopName">会员账号：</label>
						<input type='text' placeholder="会员账号" id='loginName' name='loginName' class='form-control' value='<{$loginName}>'/>
					</div>
       				<div class="form-group">
						<label class="sr-only" for="shopName">手机号码：</label>
						<input type='text' placeholder="手机号码" id='userPhone' name='userPhone' class='form-control' value='<{$userPhone}>'/>
					</div>  
       				<div class="form-group">
						<label class="sr-only" for="shopName">电子邮箱：</label>
						<input type='text' placeholder="电子邮箱" id='userEmail' name='userEmail' class='form-control' value='<{$userEmail}>'/>
					</div>  
       				<div class="form-group">
						<label class="sr-only" for="shopName">会员类型：</label>
						<select id='userType' name='userType' class="form-control">
				           <option value='-1' <if condition=" $userType eq -1 ">selected</if>>全部</option>
				           <option value='0' <if condition=" $userType eq 0 ">selected</if>>普通会员</option>
				           <option value='1' <if condition=" $userType eq 1 ">selected</if>>店铺会员</option>
				       </select>
				    </div>  
  					<button type="submit" class="btn green">
					搜索  <i class="fa fa-search"></i>
					</button>     
       			</form>
       			</div>
        <table class="table table-hover table-striped table-bordered">
           <thead>
             <tr>
               <th width='5%' style="text-align:center">序号</th>
               <th width=''>账号</th>
               <th width='10%'>用户名</th>
               <th width='10%'>手机号码</th>
               <th width='10%'>电子邮箱</th> 
               <th width='5%'>积分</th>
               <th width='10%'>等级</th>
               <th width='13%'>注册时间</th>
               <!-- <th width='13%'>最后登录时间</th> -->
               <th width='5%' style="text-align:center">状态</th>
               <th width='12%' style="text-align:center">操作</th>
             </tr>
           </thead>
           <tbody>
            <volist name="PQ['list']" id="vo" key='i'>
             <tr>
               <td style="text-align:center"><{$i}></td>
               <td><{$vo['loginName']}></td>
               <td><{$vo['userName']}></td>
               <td><{$vo['userPhone']}></td>
               <td><{$vo['userEmail']}></td>
               <td><{$vo['userScore']}></td>
               <td>
               <if condition="$vo['userType']==0 ">
               <{$vo['userRank']}>
               <else/>
              ---
               </if>
               </td>
               <td><{$vo['createTime']}></td>
               <!-- <td><{$vo['lastTime']}></td> -->
               <td style="text-align:center">
               
               <if condition="$vo['userStatus']==1 ">
                 <a href="#" class="userStatus btn btn-xs blue" onclick="javascript:userStatus(<{$vo['userId']}>,<{$vo['userStatus']}>)">启用</a>          
			     <else/>
			     <a href="#" class="userStatus btn btn-xs default"  onclick="javascript:userStatus(<{$vo['userId']}>,<{$vo['userStatus']}>)">停用</a> 
               </if>
               </td>
               <td style="text-align:center">
               <a class="edit btn btn-xs default" href="<{:U('edit',array('id'=>$vo['userId']))}>"><i class="fa fa-edit"></i> 修改</a><a class="delete btn btn-xs red" href="javascript:void(0);"  onclick="javascript:delUsers(<{$vo['userId']}>,<{$vo['userType']}>)"><i class="fa fa-trash-o"></i> 删除</a>
               </td>
             </tr>
             </volist>
           </tbody>
        </table>
        <{$PQ['page']}>
</div>
		</div>
	</div>
</div>

</block>